export const post = function (url: string, data?: any) {
	//重新上报次数
	return new Promise((resolve, reject) => {
		try {
			let xhr = new XMLHttpRequest();
			xhr.open('POST', url, true);			
			xhr.onreadystatechange = function () {
				if (4 == xhr.readyState) {
					let data = {};
					try {
						data = xhr.responseText ? JSON.parse(xhr.responseText) : {};
					} catch (e) {
						data = {};
					}
					resolve(data);
				}
			};
			xhr.onerror = function () {
				reject();
			};
			let params = JSON.stringify(data || {});
			xhr.send(params);
		} catch (e) {
			reject(e);
		}
	});
};
